package com.example.apidocserver.domain.user.service.impl;

import com.example.apidocserver.domain.user.dao.UsrUserDataRoleDao;
import com.example.apidocserver.domain.user.entity.UsrUserDataRole;
import com.example.apidocserver.domain.user.service.UsrUserDataRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户数据角色表(UsrUserDataRole)表服务实现类
 *
 * @author makejava
 * @since 2023-05-10 23:05:57
 */
@Service("usrUserDataRoleService")
@Slf4j
public class UsrUserDataRoleServiceImpl implements UsrUserDataRoleService {
    @Resource
    private UsrUserDataRoleDao usrUserDataRoleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public UsrUserDataRole queryById(Long userId) {
        return this.usrUserDataRoleDao.queryById(userId);
    }

    /**
     * 查询所有对象
     *
     * @return 查询结果
     */
    @Override
    public List<UsrUserDataRole> queryAll() {
        return this.usrUserDataRoleDao.queryAll();
    }

    /**
     * 根据对象查询
     *
     * @param usrUserDataRole 筛选条件
     * @return 查询结果
     */
    @Override
    public List<UsrUserDataRole> queryByEntity(UsrUserDataRole usrUserDataRole) {
        return this.usrUserDataRoleDao.queryByEntity(usrUserDataRole);
    }

    /**
     * 新增数据
     *
     * @param usrUserDataRole 实例对象
     * @return 实例对象
     */
    @Override
    public UsrUserDataRole insert(UsrUserDataRole usrUserDataRole) {
        this.usrUserDataRoleDao.insert(usrUserDataRole);
        return usrUserDataRole;
    }

    /**
     * 修改数据
     *
     * @param usrUserDataRole 实例对象
     * @return 实例对象
     */
    @Override
    public UsrUserDataRole update(UsrUserDataRole usrUserDataRole) {
        this.usrUserDataRoleDao.update(usrUserDataRole);
        return this.queryById(usrUserDataRole.getUserId());
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long userId) {
        return this.usrUserDataRoleDao.deleteById(userId) > 0;
    }
}
